<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html; charset=utf-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>平台管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
    <style>
        thead tr th{text-align: center!important;}
        tr td{text-align: center!important;}
        .operation button{
            margin: 3px;
        }
    </style>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <form action="/cash/cashDetail" id="seachFrom" class="layui-form">
                    <div class="layui-card-body">
                        <div class="layui-container" style="padding-bottom: 50px">
                            <div class="layui-col-md12">
                                <div class="layui-col-md4">
                                    <div class="layui-col-sm3" style="line-height: 38px">时间范围</div>
                                    <div class="layui-col-sm7">
                                        <input class="layui-input" name="queryTime" id="laydate-cn" autocomplete="off">
                                    </div>
                                </div>
                                <div class="layui-col-md3">
                                    <div class="layui-col-sm3" style="line-height: 38px">提现类型</div>
                                    <div class="layui-col-sm7">
                                        <select name="type" class="select">
                                            <option value="">全部</option>
                                            <c:forEach var="t" items="${typeTypeList }">
                                            	<option value="${t.id }" ${detail.type == t.id ? "selected='selected'":"" }>${t.name }</option>
                                            </c:forEach>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-col-md3">
                                    <div class="layui-col-sm3" style="line-height: 38px">状态</div>
                                    <div class="layui-col-sm7">
                                        <select name="status" class="select">
                                            <option value="">请选择</option>
                                            <option value="1">待审核</option>
                                            <option value="2">审核通过</option>
                                            <option value="3">审核驳回</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-col-md2">
                                    <div class="layui-col-sm3">
                                        <button class="layui-btn layui-btn" type="submit">查询</button>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md12">&nbsp;</div>
                            <div class="layui-col-md12">
                                <div class="layui-col-md3">
                                    <div class="layui-col-sm3" style="line-height: 38px">流水号</div>
                                    <div class="layui-col-sm7">
                                        <input class="layui-input" name="payCode" autocomplete="off">
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <div class="layui-col-sm3" style="line-height: 38px">手机号</div>
                                    <div class="layui-col-sm7">
                                        <input class="layui-input" name="phone" autocomplete="off">
                                    </div>
                                </div>
                                <div class="layui-col-md3">
                                    <div class="layui-col-sm3" style="line-height: 38px">真实姓名</div>
                                    <div class="layui-col-sm7">
                                        <input class="layui-input" name="realName" autocomplete="off">
                                    </div>
                                </div>                             
                            </div>
                            <div class="layui-col-md12"><hr></div>
                        </div>
                        <table class="layui-table">
                            <thead>
                            <tr>
                                <th>流水号</th>
                                <th>手机号</th>
                                <th>真实姓名</th>
                                <th>银行</th>
                                <th>支行</th>
                                <th>银行卡号</th>
                                <th>申请金额</th>
                                <th>应到账</th>
                                <th>提现类型</th>
                                <th>状态</th>
                                <th>驳回原因</th>
                                <th>申请时间</th>
                                <th>推荐人</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <c:forEach items="${pageInfo.records}" var="l">
                                <tr>
                                    <td>${l.payCode}</td>
                                    <td>${l.phone}</td>
                                    <td width="7%">${l.realName}</td>
                                    <td>${l.bankName}</td>
                                    <td>${l.bankAddr}</td>
                                    <td>${l.bankCode}</td>
                                    <td width="8%">${l.cashMoney}</td>
                                    <td width="8%">${l.realMoney}</td>
                                    <td>${l.cashTypeName}</td>
                                    <td width="7%">
                                        <c:if test="${l.status==1}">待审核</c:if>
                                        <c:if test="${l.status==2}">审核通过</c:if>
                                        <c:if test="${l.status==3}">审核驳回</c:if>
                                    </td>
                                    <td>${l.remark }</td>
                                    <td width="12%"><fmt:formatDate value="${l.createTime}" pattern="yyyy-MM-dd HH:mm"></fmt:formatDate></td>
                                    <td width="12%">${l.parentName}</td>
                                    <td>
                                    	<div class="operation">
	                                        <c:if test="${l.status == 1}">
	                                            <button data-id="${l.id}" data-status="3" data-type="rejectThis" type="button"
	                                                    class="layui-btn layui-btn-sm layui-btn-warm rejectThis">驳回</button>
	                                            <br>
	                                            <button data-id="${l.id}" data-status="2" data-type="updateThis" type="button"
	                                                    class="layui-btn layui-btn-sm layui-btn-normal updateThis">通过</button>
	                                        </c:if>
	                                        <button data-id="${l.targetId}" data-type="${l.type }" type="button"
	                                                    class="layui-btn layui-btn-sm layui-btn detailThis">查看明细</button>
                                        </div>
                                    </td>
                                </tr>
                            </c:forEach>
                            </tbody>
                        </table>
                        <div class="test-table-reload-btn" style="margin-top: 10px;">
                            <%@include file="../paging.jsp" %>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script src="/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'laydate','form'], function(){
        var laydate = layui.laydate,form=layui.form;
        form.render()
        var today = new Date();
        var last = today.getFullYear() + "-" + today.getMonth() + "-" +today.getDate();
        today = today.getFullYear() + "-" + (today.getMonth()+1) + "-" +today.getDate();
        laydate.render({
            elem: '#laydate-cn',
            range:'~',
            max:today
        });

        var active = {
            updateThis:function (id,status,url) {
                layer.confirm('确定操作吗？', function(){
                    $.ajax({
                        url: url,
                        data: {"id": id, 'status': status},
                        dataType: "json",
                        type: "post",
                        success: function (data) {
                            if (data.status) {
                                layer.msg(data.desc);
                                setTimeout(function () {
                                    window.location.reload();
                                }, 1000)
                            } else {
                                layer.msg(data.desc);
                            }
                        }
                    });
                });
            },
            rejectThis:function (id,status,url) {
            	layer.prompt({title: '驳回提现申请', formType: 2}, function(text, index){
					$.ajax({
						type: 'post',
						url: url,
						data: {'id': id, 'status': status, 'remark':text},
						dataType: 'json',
						success: function (data) {
							if (data.status) {
								layer.msg(data.desc);
								setTimeout(function () {
									window.location.reload();
								}, 1000)
							} else {
								layer.msg(data.desc);
							}
						},
						error: function (a,b,c) {
							layer.msg("请检查页面信息是否正确");
						}
					});
				});
            }
        };

        $('.updateThis').on('click',function () {
            var updateType = $(this).data('type');
            var id = $(this).data('id');
            var status = $(this).data('status');
            var url = "/cash/editCashApplyStatus";
            active[updateType] && active[updateType].call(this,id,status,url);
        })
        
        $('.rejectThis').on('click',function () {
            var updateType = $(this).data('type');
            var id = $(this).data('id');
            var status = $(this).data('status');
            var url = "/cash/editCashApplyStatus";
            active[updateType] && active[updateType].call(this,id,status,url);
        })
        
        //查看明细
        $('.detailThis').on('click',function () {
            var type = $(this).data('type');
            var id = $(this).data('id');
            var url = '';
            if(type == 1){
            	url='/customer/customerMoney?cid='+id
            }else if(type == 2){
            	url = '/account/businessAccountDetail?bid='+id
            }else if(type == 4){
            	url='/agent/accountDetail?agid='+id
            }
            window.location.href = url;
        })
        
        
    });
</script>
</body>
</html>